{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Check Phrasal paper to see how they split the corpus\n",
    "# they only use en-fr from autodesk, not en-de"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import codecs\n",
    "from collections import Counter, OrderedDict, defaultdict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# train_source_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/autodesk.train.en.bpe'\n",
    "# train_target_file = '/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/autodesk.train.de.bpe'\n",
    "\n",
    "source_tm_file = '/media/1tb_drive/parallel_data/wmt16_IT_domain/in_domain_train/indomain_training/indomain.de-en.en.bpe'\n",
    "target_tm_file = '/media/1tb_drive/parallel_data/wmt16_IT_domain/in_domain_train/indomain_training/indomain.de-en.de.bpe'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# LOAD dev source, get all constraints, write json file with those constraints"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_segments_from_file(filename):\n",
    "    with codecs.open(filename, encoding='utf8') as inp:\n",
    "        for i, l in enumerate(inp):\n",
    "            yield l.strip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "source_seg_iter = get_segments_from_file(source_tm_file)\n",
    "target_seg_iter = get_segments_from_file(target_tm_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "term_pair_map = {k:v for k,v in zip(source_seg_iter, target_seg_iter)\n",
    "                 if len(k) > 10 and len(k) < 50\n",
    "                 and len(v) > 10 and len(v) < 50\n",
    "                 and abs(len(k) - len(v)) < 15}\n",
    "src_rules = [src for src in term_pair_map.keys()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# create terminology spotter\n",
    "from semantic_annotator.spotting import MatchSpotter\n",
    "\n",
    "term_spotter = MatchSpotter(rules=src_rules)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# import the tokenized and bpe encoded dev lines\n",
    "# prepped_dev_lines = codecs.open('/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/autodesk.dev.1000.en.bpe',\n",
    "#                                  encoding='utf8').read().strip().split('\\n')\n",
    "\n",
    "# prepped_dev_lines = codecs.open('/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-fr/autodesk.dev.1000.en.bpe',\n",
    "#                                  encoding='utf8').read().strip().split('\\n')\n",
    "\n",
    "prepped_dev_lines = codecs.open('/media/1tb_drive/parallel_data/wmt16_IT_domain/in_domain_test/refs/en-de/Batch3a_en.bpe',\n",
    "                                 encoding='utf8').read().strip().split('\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "key: \" Ju@@ iced ( series ) \" val: \" Ju@@ iced ( Spiel@@ es@@ erie ) \"\n",
      "key: Pat@@ tern color : val: Muster@@ farbe :\n",
      "key: _ Top of Page ( Header ) val: O _ ben ( Seiten@@ kopf )\n",
      "key: \" Az@@ tec Code \" val: Az@@ tec@@ -Code\n",
      "key: NOR@@ MD@@ IST val: NOR@@ M@@ VER@@ T\n",
      "key: Mind@@ View val: Mind@@ View\n",
      "key: 13@@ x@@ 19 val: 13@@ x@@ 19\n",
      "key: < = : Less than or equal to val: < = : kleiner gleich\n",
      "key: Not With Report Header val: Nicht mit Bericht@@ sk@@ opf\n",
      "key: The < quote > Module < / quote > val: Die < quote > Module < / quote >\n",
      "key: app@@ end : value is not an object val: app@@ end : Der Wert ist kein Objekt\n",
      "key: of the sum of val: der Summe von\n",
      "key: \" Ser@@ endi@@ pity ( software ) \" val: \" Ser@@ endi@@ pity ( Software ) \"\n",
      "key: No content found in the document val: Das Dokument hat keinen Inhalt .\n",
      "key: Vis@@ ited Link val: Gesicht@@ eter Link\n",
      "key: Split main window horizontally val: Haupt@@ fenster wa@@ ager@@ echt aufteilen\n",
      "key: \" RAM drive \" val: RA@@ M-@@ Disk\n",
      "key: Scan directories recur@@ sively val: Ordner re@@ kur@@ siv durchsuchen\n",
      "key: Investment details val: Investitions@@ details\n",
      "key: Remove Elements val: Elemente entfernen\n",
      "key: & Ign@@ ore Players val: Spieler & ignorieren\n",
      "key: Is proportional to val: Ist proportional ( pro@@ p )\n",
      "key: \" Star Trek ( text game ) \" val: \" Star Trek ( Computer@@ spiel ) \"\n",
      "key: R ~ un Mac@@ ro ... val: Mak@@ ro aus ~ führen ...\n",
      "key: Meta Data F@@ et@@ cher val: Metad@@ at@@ en-@@ La@@ der\n",
      "key: \" Ivan Nob@@ le \" val: \" Ivan Nob@@ le \"\n",
      "key: Always Visi@@ ble val: Immer sichtbar\n",
      "key: Information for the Title Page val: Informationen für die Titel@@ folie\n",
      "key: En@@ cryp@@ tion key : val: Art der Verschlüsselung :\n",
      "key: \" Apache J@@ Meter \" val: \" Apache J@@ Meter \"\n",
      "key: Plasma Storage Resource val: Plas@@ ma-@@ Ressourcen@@ speicher\n",
      "key: \" R@@ IS ( file format ) \" val: \" R@@ IS ( Datei@@ format ) \"\n",
      "key: AND Operator [ Runtime ] val: Operator \\ \" AND \\ \" [ Laufzeit ]\n",
      "key: \" Directive ( programming ) \" val: Comp@@ il@@ er-@@ Anweisung\n",
      "key: 2.0 ( & k@@ de ; 4.@@ 11 ) val: 2.0 ( & k@@ de ; 4.@@ 11 )\n",
      "key: \" Grid Comp@@ ass \" val: \" G@@ Ri@@ D Comp@@ ass 1100 \"\n",
      "key: En@@ able streaming of all ES val: Streaming von allen ES aktivieren\n",
      "key: Burning Speed : val: Brenn@@ geschwindigkeit :\n",
      "key: Ubuntu ( and derivatives ) val: Ubuntu ( und ab@@ geleitete )\n",
      "key: Existing rules val: Best@@ ehende Regeln\n",
      "key: \" War Th@@ under \" val: \" War Th@@ under \"\n",
      "key: Time@@ Prep@@ ar val: Zeit@@ bedarf\n",
      "key: - un@@ defined - val: - un@@ definiert -\n",
      "key: Voc@@ abulary data for Plas@@ mo@@ ids val: Vok@@ abul@@ ard@@ aten für Plas@@ mo@@ ide\n",
      "key: Release of KDE Fr@@ ameworks 5.@@ 5.0 val: Veröffentlichung der KDE Fr@@ ameworks 5.@@ 5.0\n",
      "key: Microsoft Sound@@ ma@@ pper val: Microsoft Sound@@ ma@@ pper\n",
      "key: , but only from word % 1 to word % 2 val: , aber nur von Wort % 1 bis Wort % 2\n",
      "key: Former Core Developer val: Ehem@@ al@@ iger Haupt@@ entwickler\n",
      "key: R & est@@ art Server val: & Server neu starten\n",
      "key: Tel@@ er@@ adi@@ ology val: Tel@@ er@@ adi@@ ologie\n",
      "key: Items to include val: Bestandteile\n",
      "key: Custom@@ izing L@@ ook@@ up Fol@@ ders val: Such@@ ordner einrichten\n",
      "key: Del@@ etes the selected item val: Lö@@ scht das ausgewählte Objekt\n",
      "key: \" Miller – Rab@@ in prim@@ ality test \" val: Mill@@ er-@@ Rab@@ in-@@ Test\n",
      "key: Rec@@ ur@@ sively query resources val: Ressourcen re@@ kur@@ siv abfragen\n",
      "key: \" Jürgen Schmid@@ huber \" val: \" Jürgen Schmid@@ huber \"\n",
      "key: Right and left val: Rechts und Links\n",
      "key: \" J@@ eri@@ cho ( missile ) \" val: \" J@@ eri@@ cho ( Rakete ) \"\n",
      "key: Proc@@ essed revision % s val: Revision % s bearbeitet\n",
      "key: Matthias El@@ ter val: Matthias El@@ ter\n",
      "key: Tre@@ ble Up val: Höhen anheben\n",
      "key: Automatically load / save configuration . val: Konfiguration automatisch laden / speichern .\n",
      "key: A warning message is being shown val: Eine Warn@@ meldung wird angezeigt\n",
      "key: Office Supp@@ lies val: Büro@@ material\n",
      "key: Create table val: Tabelle erstellen\n",
      "key: Registration FA@@ IL@@ ED val: Registrierung fehl@@ geschlagen\n",
      "key: Black and Yellow val: Schwarz und Gel@@ b\n",
      "key: Highlight b@@ ac & k@@ ground : val: Hinter & grund@@ farbe für Hervorh@@ ebung :\n",
      "key: Fi@@ j@@ ian Dollar val: F@@ id@@ schi@@ -@@ Dollar\n",
      "key: _ Enter password to open val: _ Kennwort zum Öffnen eingeben\n",
      "key: Super@@ vis@@ or@@ ID val: Ab@@ teilungs@@ lei@@ ter@@ ID\n",
      "key: % 1 page ( s ) val: % 1 Seite ( n )\n",
      "key: Rep@@ eating possible val: Nach@@ sprechen möglich\n",
      "key: Freeri@@ ce val: Free@@ Rice\n",
      "key: \" Less ( sty@@ les@@ he@@ et language ) \" val: \" Less ( Styl@@ es@@ he@@ et-@@ Sprache ) \"\n",
      "key: Sim@@ ulating second session val: Zweite Sitzung wird simu@@ liert\n",
      "key: Last change date val: Letztes Änderungs@@ datum\n",
      "key: View Design ... val: An@@ sichts@@ entwurf ...\n",
      "key: Ren@@ ame Auto@@ Text val: Text@@ bau@@ stein um@@ benennen\n",
      "key: Show seeds in s@@ war@@ ms val: Se@@ eder in Sch@@ wärmen anzeigen\n",
      "key: Delete cas@@ cade val: K@@ ask . Löschen\n",
      "key: User is speaking val: Benutzer spricht\n",
      "key: overlay deleted val: Gel@@ ö@@ scht\n",
      "key: Minor inter _ val val: Hilfs@@ inter _ v@@ all\n",
      "key: \" Par@@ ticle in a ring \" val: \" Teilchen auf dem Ring \"\n",
      "key: IP@@ Filter val: IP@@ Filter\n",
      "key: < entry > 2 < / entry > val: < entry > 2 < / entry >\n",
      "key: Select All En@@ tries val: Alle Einträge auswählen\n",
      "key: Please enter a valid E-Mail Address . val: Bitte geben Sie eine gültige E-Mail-Adresse ein .\n",
      "key: & Jab@@ ber ID : val: & Jab@@ ber-@@ ID :\n",
      "key: Ex@@ tract and En@@ code Audio Tracks val: Musik@@ stücke aus@@ lesen und ko@@ dieren\n",
      "key: \" List of e@@ Sports games \" val: \" Disziplinen im E@@ -S@@ port \"\n",
      "key: Only enable on public tor@@ rents val: Nur bei öffentlichen Tor@@ rents aktivieren\n",
      "key: < emphasis > 5 < / emphasis > val: < emphasis > 5 < / emphasis >\n",
      "key: Map & Name ... val: & Name der Karte ...\n",
      "key: Ph@@ one@@ Sat val: Ph@@ one@@ Sat\n",
      "key: Con@@ firm end of reconciliation val: Ende des Ab@@ gleich@@ s bestätigen\n",
      "key: g@@ it@@ orious val: g@@ it@@ orious\n",
      "key: Help Im@@ prove the Application val: Mithilfe bei Anwendungs@@ verbesserung\n",
      "key: Show Solution val: Lösung anzeigen\n"
     ]
    }
   ],
   "source": [
    "for k,v in term_pair_map.items()[:100]:\n",
    "    print(u'key: {} val: {}'.format(k,v))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\" Computer@@ ized maintenance management system \"\n",
      "\" Computer@@ ized Maintenance Management System \"\n"
     ]
    }
   ],
   "source": [
    "keys_by_len = sorted(src_rules, key=lambda x: len(x))\n",
    "print(keys_by_len[-100])\n",
    "print(term_pair_map[keys_by_len[-100]])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Preferences\n",
      "Screen Sa@@ ver\n",
      "Control Panel\n",
      "Preferences\n",
      "Control Panel\n",
      "Alternative\n",
      "Spo@@ t@@ light\n",
      "Control Panel\n",
      "Control Panel\n",
      "Preferences\n",
      "Preferences\n",
      "Advanced Options\n",
      "Alternative\n",
      "Double click\n",
      "Select the file\n",
      "My Computer\n",
      "Computer Name\n",
      "My Computer\n",
      "Computer Name\n",
      "description\n",
      "Format@@ ting\n",
      "lower@@ case\n",
      "Dis@@ connect\n",
      "signal strength\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Navig@@ ate\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Fac@@ e@@ Time\n",
      "Preferences\n",
      "Account Information\n",
      "Scroll down\n",
      "Y@@ C@@ b@@ C@@ r\n",
      "Purch@@ ased\n",
      "Choose File\n",
      "Open System\n",
      "Control Panel\n",
      "Choose File\n",
      "New Account\n",
      "My Computer\n",
      "Do Not Di@@ stur@@ b\n",
      "Do Not Di@@ stur@@ b\n",
      "Create an account\n",
      "credit card\n",
      "notification\n",
      "notification\n",
      "Right click\n",
      "Control Panel\n",
      "Right click\n",
      "read-@@ only\n",
      "Cyber@@ Link\n",
      "Drag and drop\n",
      "Blu@@ es@@ creen\n",
      "configuration\n",
      "Downlo@@ ading\n",
      "N@@ vi@@ dia\n",
      "Back@@ space\n",
      "small square\n",
      "Wra@@ p Text\n",
      "Page Layout\n",
      "Page Layout\n",
      "Page Layout\n",
      "Insert Page Break\n",
      "Page Layout\n",
      "Page Layout\n",
      "Navig@@ ate\n",
      "Navig@@ ate\n",
      "pus@@ h@@ pin\n",
      "pus@@ h@@ pin\n",
      "Recent Documents\n",
      "auto-@@ save\n",
      "Page Layout\n",
      "Ori@@ entation\n",
      "orientation\n",
      "Page Layout\n",
      "Page Layout\n",
      "Page Layout\n",
      "Page Layout\n",
      "Wid@@ th and Hei@@ ght\n",
      "Alternative\n",
      "Show / Hi@@ de\n",
      "Page Layout\n",
      "Wra@@ p Text\n",
      "Com@@ press\n",
      "Bring Forward\n",
      "Send Back@@ ward\n",
      "Convert Text to Table\n",
      "Separ@@ ate\n",
      "Delete Cells\n",
      "Sp@@ elling\n",
      "one or more\n",
      "Bal@@ lo@@ ons\n",
      "Bal@@ lo@@ ons\n",
      "Rev@@ isions\n",
      "right margin\n",
      "Protect Document\n",
      "Format@@ ting\n",
      "Save Current\n",
      "Create from\n",
      "Link to file\n",
      "Gar@@ age@@ Band\n",
      "development\n",
      "Right click\n",
      "Preferences\n",
      "Preferences\n",
      "Ex@@ tensions\n",
      "Control Panel\n",
      "Presentation\n",
      "Alternative\n",
      "One@@ Drive\n",
      "Pres@@ ent@@ ations\n",
      "pus@@ h@@ pin\n",
      "Pres@@ ent@@ ations\n",
      "Apply to All\n",
      "Operating System\n",
      "Preferences\n",
      "Transi@@ tions\n",
      "Transi@@ tions\n",
      "Effect Options\n",
      "Un@@ titled\n",
      "High@@ lighter\n",
      "Line Spac@@ ing\n",
      "Com@@ press\n",
      "Line Spac@@ ing\n",
      "Add Book@@ mark\n",
      "Current Frame\n",
      "Stop button\n",
      "Select a file\n",
      "Play / Pause\n",
      "Play / Pause\n",
      "Select the file\n",
      "F@@ ade Out\n",
      "Add Book@@ mark\n",
      "book@@ mark\n",
      "book@@ mark\n",
      "Sp@@ elling\n",
      "one or more\n",
      "Navig@@ ate\n",
      "Sp@@ elling\n",
      "Rev@@ isions\n",
      "Presentation\n",
      "Sli@@ de Master\n",
      "Close Master View\n",
      "Sli@@ de Master\n",
      "Navig@@ ate\n",
      "Sli@@ de Master\n",
      "Hyper@@ link .\n",
      "Hyper@@ link .\n",
      "Email Address\n",
      "email address\n",
      "Remove Hyper@@ link\n",
      "Create from file\n",
      "Link to file\n",
      "Right click\n",
      "Right click\n",
      "work address\n",
      "Min@@ ecraft\n",
      "Navig@@ ate\n",
      "Mag@@ ni@@ fication\n",
      "Preferences\n",
      "Preferences\n",
      "Add a contact\n",
      "Internet Explorer\n",
      "Internet Explorer\n",
      "No@@ tification\n",
      "Book@@ marks\n",
      "book@@ mark\n",
      "Book@@ marks\n",
      "Book@@ mark Manager\n",
      "Book@@ mark Manager\n",
      "book@@ mark\n",
      "Archi@@ ved\n",
      "Network Monitor\n",
      "Create an account\n",
      "Web History\n",
      "D@@ ashboard\n",
      "Select File\n",
      "Select the file\n",
      "Select the file\n",
      "Select the file\n",
      "Visi@@ bility\n",
      "Sp@@ read@@ sheet\n",
      "Un@@ titled\n",
      "Back@@ space\n",
      "configuration\n",
      "Ren@@ ame ...\n",
      "Dup@@ lic@@ ate\n",
      "One@@ Drive\n",
      "One@@ Drive\n",
      "One@@ Drive\n",
      "One@@ Drive\n",
      "One@@ Drive\n",
      "Ori@@ entation\n",
      "Insert Page\n",
      "publication\n",
      "Wra@@ p Text\n",
      "Create Link\n",
      "publication\n",
      "Hy@@ phen@@ ation\n",
      "Bring Forward\n",
      "Send Back@@ ward .\n",
      "check spelling\n",
      "Categ@@ orize\n",
      "All Categ@@ ories\n",
      "Categ@@ orize\n",
      "notification\n",
      "prel@@ o@@ ad\n",
      "En@@ cryp@@ tion\n",
      "Wh@@ ats@@ App\n",
      "Open Source\n",
      "Display settings\n",
      "Control Panel\n",
      "Right click\n",
      "the total size of\n",
      "Chrom@@ ebook\n",
      "Real@@ Player\n",
      "Preferences\n",
      "Noti@@ fications\n",
      "Short@@ cuts\n",
      "Applications\n",
      "Applications\n",
      "Download Manager\n",
      "Preferences\n",
      "My Computer\n",
      "Right click\n",
      "notification\n",
      "Default gateway\n",
      "Dro@@ p@@ box\n",
      "local@@ host\n",
      "Purch@@ ased\n",
      "Screen Sa@@ ver\n",
      "Mozilla Firefox\n",
      "Inst@@ ag@@ ram\n",
      "Accessories\n",
      "Preferences\n",
      "Automatically\n",
      "Li@@ bre@@ Office\n",
      "File system\n",
      "Dep@@ ends on\n",
      "Right click\n",
      "File Manager\n",
      "File Manager\n",
      "Right click\n",
      "Administrator\n",
      "Tru@@ e@@ Cryp@@ t\n",
      "V@@ LC media player\n",
      "Control Panel\n",
      "Dro@@ p@@ box\n",
      "Applications\n",
      "Tum@@ bl@@ r\n",
      "One@@ Drive\n",
      "Right click\n",
      "Un@@ install\n",
      "Sc@@ ale Image\n",
      "pixels / inch\n",
      "Right click\n",
      "Advanced Options\n",
      "configuration\n",
      "Control Panel\n"
     ]
    }
   ],
   "source": [
    "dev_term_spots = []\n",
    "for l in prepped_dev_lines:\n",
    "    spots = term_spotter.get_spots(l)\n",
    "    dev_term_spots.append(spots)\n",
    "\n",
    "dev_term_constraints = []\n",
    "for text, spots in zip(prepped_dev_lines, dev_term_spots):\n",
    "    output_constraints = []\n",
    "    if len(spots) > 0:\n",
    "        for spot in spots:\n",
    "            if spot[1] - spot[0] > 1:\n",
    "                spotted_term = text[spot[0]:spot[1]]\n",
    "                print(spotted_term)\n",
    "                mapped_term = term_pair_map[spotted_term]\n",
    "                output_constraints.append(mapped_term.split())\n",
    "    dev_term_constraints.append(output_constraints)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1000"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(dev_term_constraints)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import json\n",
    "\n",
    "# OUTPUT_DIR='/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus'\n",
    "# OUTPUT_DIR='/home/chris/projects/constrained_decoding/proto/autodesk_constrained_decoding_corpus/en-fr'\n",
    "OUTPUT_DIR='/media/1tb_drive/parallel_data/wmt16_IT_domain/in_domain_test/refs/en-de/'\n",
    "\n",
    "with codecs.open(os.path.join(OUTPUT_DIR, 'tm.test.constraints.json'), 'w', encoding='utf8') as out:\n",
    "    out.write(json.dumps(dev_term_constraints, indent=2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
